package net.feixiang.creational.singleton.staticClass;

/**
 * 调用静态内部类单例类的示例程序
 *
 * @author 飞翔
 * @see <a href="https://www.feixiang.net/Java%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E7%AC%AC%E4%B8%80%E7%AB%A0%E3%80%81%E5%88%9B%E5%BB%BA%E5%9E%8B%E6%A8%A1%E5%BC%8F/11.html">单例模式</a>
 */
public class StaticClassSingletonDemo {
    public static void main(String[] args) {
        // 获取单例实例
        StaticClassSingleton singleton = StaticClassSingleton.getInstance();
        // 调用单例实例的方法
        for (int i = 0; i < 3; i++) {
            singleton.doSomething();
            // 输出单例实例的哈希码以判断是否是同一个实例
            System.out.println(singleton.hashCode());
        }
    }
}
